package cn.wizzer.app.user.modules.models.vo;

import cn.wizzer.app.match.modules.models.constant.Fields;
import cn.wizzer.app.user.modules.models.User;
import cn.wizzer.framework.util.JSONUtil;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

@Data
public class LiveInfo implements Serializable {


    private String liveCode;

    /**
     * 官方
     */
    private boolean official;

    /**
     * 公告
     */
    private String notice;

    private MatchLives matchInfo;

    private String homeName;

    private String awayName;

    public LiveInfo() {
        this.userCount = 0L;
    }

    public LiveInfo(String userId, String videoId) {
        this.userId = userId;
        this.videoId = videoId;
    }

    /**
     * @param userId
     * @param league
     * @param streamUrl
     * @param nickName
     * @param headPicture
     * @param videoId
     * @param userCount
     * @author 沧海一粟
     * @method AnchorInfo
     * @date 2019/12/12 10:27
     */
    public LiveInfo(String userId, String league, String streamUrl, String nickName, String sign, String headPicture,
                    String category, String videoId, String coverPic,String labels, Long userCount) {
        this.userId = userId;
        this.league = league;
        this.streamUrl = streamUrl;
        this.nickName = nickName;
        this.sign = sign;
        this.headPicture = headPicture;
        this.category = category;
        this.videoId = videoId;
        this.coverPic = coverPic;
        this.labels = labels;
        this.userCount = userCount;
        this.id = userId + Fields._AND_ + videoId;
        this.official = true;
    }


    /**
     * 皇冠赛事Id
     */
    private String matchId;
    /**
     * 直播间ID
     */
    private String id;

    /**
     * 主播ID
     */
    private String userId;

    /**
     * 所属联赛
     */
    private String league;

    /**
     * 直播流地址
     */
    private String streamUrl;

    /**
     * 封面图
     */
    private String coverPic;

    /**
     * 用户昵称
     */
    private String nickName;

    /**
     * 直播标题
     */
    private String title;

    /**
     * 直播签名
     */
    private String sign;

    /**
     * 主播头像
     */
    private String headPicture;

    /**
     * 分类名
     */
    private String category;

    /**
     * 在线人数
     */
    private Long userCount;

    /**
     * 推流ID
     */
    private String videoId;

    /**
     * 推荐值-倒叙
     */
    private int recommend;

    /**
     * 标签
     */
    private String labels;

    /**
     * 是否已删除
     */
    private boolean delFlag = false;


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        LiveInfo liveInfo = (LiveInfo) o;
        return userId.equals(liveInfo.userId) &&
                videoId.equals(liveInfo.videoId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId, videoId);
    }

    @Override
    public String toString() {
        return JSONUtil.toJSONString(this);
    }

    public void setAnchor(User user) {
        this.nickName = user.getNickName();
        this.sign = user.getSign();
        this.userId = user.getId();
        this.headPicture = user.getHeadPicture();
    }
}
